home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / ibmcom.zip / IBMCOMT.PAS < prev    next >
Pascal/Delphi Source File  |  1989-01-01  |  2KB  |  72 lines

  1. PROGRAM ibmcomt;
  2.  
  3. {Simple test program for IBMCOM.  Acts like a dumb terminal at a fixed
  4. speed and with no commands except for Alt-X, to exit the program.
  5. Obviously, it doesn't test all of IBMCOM, but it tests the most
  6. important parts -- receiving and sending characters.}
  7.  
  8.  
  9. USES
  10.   Crt, ibmcom;
  11.  
  12.  
  13. {Read a key from the keyboard.  If it's an ordinary key, the ascii code
  14. is returned in ch1 and ch2 is #0.  If it's a function key, ch1 is 0 and
  15. the scan code is in ch2.}
  16.  
  17. PROCEDURE read_key (VAR ch1, ch2: Char);
  18. BEGIN
  19.   ch1 := ReadKey;
  20.   IF ch1 = #0 THEN
  21.     ch2 := ReadKey
  22.   ELSE
  23.     ch2 := #0;
  24. END;
  25.  
  26.  
  27. CONST
  28.   port          = 1;
  29.   initial_speed = 2400;
  30.  
  31. VAR
  32.   result   : Word;
  33.   exit_prog: Boolean;
  34.   ch1, ch2 : Char;
  35.   ch3      : Char;
  36.  
  37. BEGIN
  38.   com_install (port, result);
  39.   IF result <> 0 THEN
  40.     BEGIN
  41.     CASE result OF
  42.       1: Writeln ('Invalid port number: ', port);
  43.       2: Writeln ('No hardware for port ', port);
  44.       3: Writeln ('Driver already installed');
  45.     ELSE
  46.       Writeln ('Unexpected com_install error ', result);
  47.       END;
  48.     Exit;
  49.     END;
  50.   com_raise_dtr;
  51.   com_set_speed (initial_speed);
  52.   com_set_parity (com_None, 1);
  53.   exit_prog := False;
  54.   ClrScr;
  55.   REPEAT
  56.     IF KeyPressed THEN
  57.       BEGIN
  58.       read_key (ch1, ch2);
  59.       IF ch1 <> #0 THEN
  60.         com_tx (ch1)
  61.       ELSE
  62.         CASE ch2 OF
  63.           #45: {Alt-X}
  64.             exit_prog := True;
  65.           END;
  66.       END;
  67.     ch3 := com_rx;
  68.     IF ch3 <> #0 THEN
  69.       Write (ch3);
  70.   UNTIL exit_prog;
  71. END.
  72.